<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<title>${info.title}</title>
	<link href="${app}/static/jquery-weui/css/weui.min.css" rel="stylesheet" type="text/css" />
	<link href="${app}/static/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" type="text/css" />
	<link href="${app}/static/weixin/vote/index${info.moban}/touch.css" rel="stylesheet" type="text/css" />
	<link href="${app}/static/weixin/vote/index1/common.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="${app}/static/weixin/vote/index1/webuploader.css">
	<script type="text/javascript" src="${app }/static/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	<script type="text/javascript" src="${app }/static/webuploader/dist/webuploader.min.js"></script>
	<script type="text/javascript" src="${app}/static/jquery-weui/jquery-weui.min.js"></script>
</head>
<body>

<header>
	<div class="m_head clearfix">
		<div class="num_box">
			[#include "/weixin/vote/include/voteTop.html" /]
		</div>
	</div>
</header>
<div class="apply" style="font-size: 14px;">
	<p>报名处</p>
	<div class="blank10"></div>
	<form id="signupok">
		<input type="hidden" id="accountId" name="accountId" value="${info.account_id}">
		<input type="hidden" id="id" name="id" value="${info.id}">
		<dl class="clearfix">
			<dt>姓名:</dt>
			<dd><input type="text" class="input_txt" id="itemName" name="itemName" placeholder="请输入姓名:"></dd>
		</dl>
		<dl class="clearfix">
			<dt>微信号:</dt>
			<dd><input type="text" class="input_txt" id="wechat" name="wechat" placeholder="请输入微信号:"></dd>
		</dl>
		<dl class="clearfix">
			<dt>联系电话:</dt>
			<dd><input type="text" class="input_txt" name="mobile" id="mobile" placeholder="请输入您的真实手机号"></dd>
		</dl>
		<dl class="upload clearfix">
			<dt>上传照片<br>1-${info.picnum}张:</dt>
			<dd class="upload_area clearfix">
				<ul id="imglist" class="post_imglist"></ul>
				<div id="picker" class="upload_btn">
				</div>
			</dd>
		</dl>
		<dl class="clearfix">
			<dt>参赛宣言:</dt>
			<dd><textarea class="textarea" placeholder="请输入参赛宣言" name="intro" id="intro"></textarea></dd>
		</dl>
		<div style="color: #EC6941;font-size: 16px;padding: 0 15px 15px 15px; line-height:24px; font-weight:bolder;">${info.wfbmbz}</div> <!-- 无法报名说明 -->
		<div class="btn_box">
			<input type="button" id="signup" class="button" value="确认报名" />
			<br />
			<input type="button" onclick="javascript:location.href='${app}/weixin/vote/index.shtml?id=${info.id}&accountId=${info.account_id}';" class="button" value="返回首页">
		</div>
		<div class="blank10"></div>
	</form>
</div>
[#include "/weixin/vote/include/voteRule.html" /]
[#include "/weixin/vote/include/voteFooter2.html" /]
</body>
<script type="text/javascript">
	var uploader = WebUploader.create({
		// 选完文件后，是否自动上传。
		auto: true,
		// swf文件路径
		swf: '${app}/static/webuploader/dist/Uploader.swf',
		method: 'POST',
		// 文件接收服务端。
		server: '${app}/sysmgr/file/upload.do',
		// 设置文件上传域的name
		fileVal: 'files',
		formData: {moduleName: '微信投票', remark: '选手图片', downloadType: '2'},
		// 选择文件的按钮。可选。
		pick: {
			id: '#picker',
			label: ''
		},
		// 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		resize: false,
		// 只允许选择图片文件。
		accept: {
			title: 'Images',
			extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/*'
		},
		fileNumLimit: '${info.picnum}'
	});
	uploader.on('uploadSuccess', function(file, resp) {
		if(resp.result == 1){
			$('<li><span class="del"></span><img class="wh60" src="${imgSite}/'+resp.filePath+'" />' +
					'<input type="hidden" name="pic" value="'+resp.filePath+'" /></li>').appendTo('#imglist');
			$(".del").on("click",function(){
				$(this).parent('li').remove();
			});
		}
	});
	$(function($){
		$("#signup").on('click', function(){
			var itemName = $("#itemName").val();
			var wechat = $("#wechat").val();
			var mobile = $("#mobile").val();
			var intro = $("#intro").val();

			if(itemName == ''){
				alert('请输入姓名');
				return false;
			}

			if(wechat == ''){
				alert('请输入微信号');
				return false;
			}

			if(mobile == ''){
				alert('请输入手机号');
				return false;
			}

			var telreg = /^1[3|4|5|7|8][0-9]\d{4,8}$/;
			if (!telreg.test(mobile)){
				alert("请输入正确的手机号！");
				return false;
			}
			if(intro == ''){
				alert('请输入参赛宣言');
				return false;
			}

			var length = $("#imglist").find("li").length;
			if(length == ''|| length == null  || length == undefined || length == 'undefined' || length < 1 ){
				alert('请上传1张以上图片');
				return false;
			}

			common.ajax('${app}/weixin/vote/saveItem.shtml', $('#signupok').serializeArray(), 'POST', 'JSON',
				false, function(result){
						$.modal({
							title: "系统提醒",
							text: result.msg,
							buttons: [
								{
									text: "确定",
									onClick: function(){
										if (result.result == 1) {
											window.location.href = '${app}/weixin/vote/itemInfo.shtml?id=${info.id}&accountId=${info.account_id}&itemId='+result.itemId;
										}
									}
								}
							]
						});
					});
		});
	});
</script>
</html>